<template>
<div class="cover_detail">
<el-button type="primary" class="goback_btn" @click="goback"> 返回 </el-button>
<el-form ref="form" :model="form" label-width="100px" class="thcat_form"  :loading="table_loading">
    <el-form-item label="图片" >
    <el-input v-model="form.avatar" :disabled="true"></el-input>
  </el-form-item>
  <el-form-item label="id" >
    <el-input v-model="form.facilityId" :disabled="true"></el-input>
  </el-form-item>
   <el-form-item label="平台id" >
    <el-input v-model="form.platformId" :disabled="true"></el-input>
  </el-form-item>
    <el-form-item label="平台名称" >
    <el-input v-model="form.platformName" :disabled="true"></el-input>
  </el-form-item>
    <el-form-item label="名称" >
    <el-input v-model="form.name" :disabled="true"></el-input>
  </el-form-item>
    <el-form-item label="支付宝名字" >
    <el-input v-model="form.isclick" :disabled="true"></el-input>
  </el-form-item>
    <el-form-item label="身份证正面" >
        <PictureView v-if="form.cardPositiveUrl" :pictureList="form.cardPositiveUrl"></PictureView>
    <!-- <el-input v-model="form.cardPositiveUrl" :disabled="true"></el-input> -->
  </el-form-item>

    <el-form-item label="身份证背面" >
  
  <PictureView v-if="form.cardBackUrl" :pictureList="form.cardBackUrl"></PictureView>
  </el-form-item>
   <el-form-item label="身份证手持" >
      <PictureView v-if="form.cardHandheldUrl" :pictureList="form.cardHandheldUrl"></PictureView>
  </el-form-item>
    <el-form-item label="审核状态" >
     
    <el-input v-model="approvalStatus_t" :disabled="true"></el-input>
  </el-form-item>
   <el-form-item label="审核回馈" >
    <el-input v-model="form.approvalFeedback" :disabled="true"></el-input>
  </el-form-item>
     <el-form-item label="更新时间" >
    <el-input v-model="updateTime_t" :disabled="true"></el-input>
  </el-form-item>
     <el-form-item label="审核时间" >
    <el-input v-model="reviewTime_t" :disabled="true"></el-input>
  </el-form-item>

   <el-button type="success" class="goback_btn" @click="show_upload">审核</el-button>

   
<!--添加用户s-->
    <el-dialog title="审核" :visible.sync="dialogFormVisible">
      <el-form :rules="rules" ref="dataForm" :model="upload_form" label-position="left" label-width="70px" style='width: 400px; margin-left:50px;'>
     
        <el-form-item label="状态" prop="approvalStatus">
          <el-select class="filter-item" v-model="upload_form.approvalStatus" placeholder="请选择状态">
            <el-option v-for="item in status" :key="item.name" :label="item.name" :value="item.value">
            </el-option>
          </el-select>
        </el-form-item>

        <el-form-item label="	意见" prop="feedback" v-show="show_report">
          <el-input v-model="upload_form.feedback" type="textarea"></el-input>
        </el-form-item>
  
      </el-form>

      <div slot="footer" class="dialog-footer">
        <el-button @click="dialogFormVisible = false">取消</el-button>
        <el-button type="primary" @click="upload">确定</el-button>
      </div>
    </el-dialog>
<!--添加用户e-->
</el-form>
</div>
</template>
<script>
import { getDetailProp } from '@/api/prop'
import moment from 'moment'
moment.lang('zh-cn')
import PictureView from 'vue-simple-picture-preview'
const log = this.log
export default {
  data() {
    return {
      status: [{ name: '审核失败', value: 0 }, { name: '审核成功', value: 3 }],
      dialogFormVisible: false,
      form: {
        userId: '',
        nickname: '',
        email: '',
        phone: '',
        updateTime: '',
        birthday: '',
        username: '',
        disabled: true
      },
      upload_form: {
        approvalStatus: '',
        feedback: ' ',
        id: '',
        userId: ''
      },
      show_report: false,
      table_loading: false,
      rules: {
        approvalStatus: [
          { required: true, message: '请选择状态', trigger: 'change' }
        ],
        feedback: [
          { required: true, message: '请输入反馈', trigger: 'blur' }
        ]
      }
    }
  },
  components: {
    PictureView
  },
  watch: {
    'upload_form.approvalStatus': function(val) {
      console.log('show_report')
      console.log(val)
      if (val === 0) {
        this.show_report = true
      } else {
        this.show_report = false
      }
    },
    lastName: function(val) {
      this.fullName = this.firstName + ' ' + val
    }
  },
  computed: {
    updateTime_t: function() {
      const temp = new Date(this.form.updateTime).getTime()
      return moment(temp).format('MMMM Do YYYY, h:mm:ss a')
    },
    reviewTime_t: function() {
      const temp = new Date(this.form.reviewTime).getTime()
      return moment(temp).format('MMMM Do YYYY, h:mm:ss a')
    },
    formateTime_t: function(val) {
      const temp = new Date(this.form.updateTime).getTime()
      return moment(temp).format('MMMM Do YYYY, h:mm:ss a')
    },
    birthday_t: function() {
      const temp = new Date(this.form.birthday).getTime()
      this.form.birthday = moment(temp).format('MMMM Do YYYY, h:mm:ss a')
      return moment(temp).format('MMMM Do YYYY, h:mm:ss a')
    },
    approvalStatus_t: function() {
      if (this.form.approvalStatus == 0) {
        return '审核失败'
      } else if (this.form.approvalStatus == 1) {
        return '提交审核'
      } else if (this.form.approvalStatus == 2) {
        return '审核中'
      } else if (this.form.approvalStatus == 3) {
        return '审核成功'
      }
      // return this.form.approvalStatus
    }
  },
  created() {
    this.table_loading = true
    this.$nextTick(() => {
      const form = JSON.parse(this.$route.query.usermsg)
      // 没有传值 就是edit
      console.log('form+++++++++++++++++++++++++++++++')
      console.log(form)
      // this.$route.query.show ? form.disabled = true : form.disabled = false
      getDetailProp(form.facilityId).then((e) => {
        this.table_loading = false
        this.form = e.data
      }).catch((e) => {
        this.table_loading = false
        console.log(e)
      })
    })
  },
  methods: {
    onSubmit() {
      console.log('submit!')
    },
    show_upload() {
      this.dialogFormVisible = true
    },
    upload() {
      this.$refs['dataForm'].validate(valid => {
        this.table_loading = true
        if (valid) {
          const temp_form = {}
          temp_form.userId = this.form.userId
          console.log('userid______________')
          console.log(this.form.userId)
          this.upload_form.userId = this.form.userId
          // Object.assign(this.upload_form, temp_form)
          // tempData.timestamp = +new Date(tempData.timestamp) // change Thu Nov 30 2017 16:41:05 GMT+0800 (CST) to 1512031311464
          editAUth(this.upload_form).then((e) => {
            this.table_loading = false
            this.log(e)
            if (e.data.code === 200) {
              this.$notify({
                title: '成功',
                message: '更新成功',
                type: 'success',
                duration: 2000,
                onClose: () => {
                  this.goback()
                }
              })
            } else {
              this.$message.error(e.data.msg)
            }
          }).catch((e) => {
            this.$message.error(e)
            this.table_loading = false
          })
        }
      })
    }
  }
}
</script>
<style lang="scss" scoped>
    .cover_detail{
      width: 100%;
      
    }
    .thcat_form{
      margin-top: 20px;
      width:50%;
    }
</style>
